from PIL import Image
import os

input_folder = 'C:/Users/EDY/Desktop/gmy'
output_folder = 'C:/Users/EDY/Desktop/验证码_gmy'

if not os.path.exists(output_folder):
    os.makedirs(output_folder)

for file in os.listdir(input_folder):
    if file.endswith('.png'):
        img = Image.open(os.path.join(input_folder, file))
        img = img.convert('RGB')  # 添加这行代码
        new_file = os.path.splitext(file)[0] + '.jpg'
        img.save(os.path.join(output_folder, new_file))
        print(f"Converted {file} to {new_file}")
